<script type="text/javascript">
$(document).ready(function(){
							$('.check').live('click',function(){
								value= $(this).val().split('_');
								soluong = $('#'+ value[1]).val();
								doanp_th =$("#thang"+value[0]).val();
								tong_thang = $('#dathu'+value[0]).val();
								tong = $('#tong').val();
								if ($(this).prop('checked')==true)
								{
									tong_thang = parseInt(tong_thang,10)  +parseInt(doanp_th,10)*parseInt(soluong,10);
									tong = parseInt(tong,10) + parseInt(doanp_th,10)*parseInt(soluong,10);
								}
								else
								{
									tong_thang = parseInt(tong_thang,10) - parseInt(doanp_th,10)*parseInt(soluong,10);
									tong = parseInt(tong,10) - parseInt(doanp_th,10)*parseInt(soluong,10);
								}
								$('#dathu'+value[0]).val(tong_thang);
								$('#tong').val(tong);
								$("td#tong"+value[0]).html(numberformat(tong_thang));
								$("td#tongtd").html(numberformat(tong));
								});
							
							$('.checkall').live('click',function(){
								chidoannum =$('#chidoan').val();
								thang = $(this).prop('id');
								doanp_th =$("#thang"+thang).val();
								tong_thang=parseInt($('#dt'+thang).val(),10);
								if ($(this).prop('checked')==true)
								{
									$("input:checkbox").each(function()
									{
										value = $(this).val().split('_');
										if (value[0]==thang)
										{
												soluong = $('#'+ value[1]).val();
												ch =true;
												tong_thang += parseInt(doanp_th,10)*parseInt(soluong,10);
										}
									});
								}
								else
								{
									tong_thang=$('#dt'+thang).val();
									ch =false;
								}
								for(i=0;i<chidoannum;i++)
								{
									$('#check'+thang+'_'+i).prop('checked',ch);
								}
								
								tong_th_trc = $('#dathu'+thang).val();
								tong_trc = $('#tong').val();
								tong =  parseInt(tong_trc,10) + (tong_thang- parseInt(tong_th_trc,10));
								$('#dathu'+thang).val(tong_thang);
								$("td#tong"+thang).html(numberformat(tong_thang));
								
								$('#tong').val(tong);
								$("td#tongtd").html(numberformat(tong));
								});
							$('#chon').change(function(){
															if($('#chon').val()==0)
																$('#khoc').show();
															else
																$('#khoc').hide();
																});
});
</script>
<script>
$(function() {
	$( "#tabs" ).tabs({
	    select: function(event, ui) {
	        var url = $.data(ui.tab, 'load.tabs');
	        if( url ) {
	            location.href = url;
	            return false;
	        }
	        return true;
	    },
	selected: 0
	});
});
</script>
<div id="tabs">
	<ul>
            <li><a href='#pt'>Đóng đoàn phí</a> </li>

    </ul>
<div class="tgdongdoanphisvs index">
<h2 style="text-align: center;">Quản lý đoàn phí</h2>
<div align="center" style="margin-top: 2px;">
<strong><?php 

    echo 'Khoa: '.$khoa['Khoa'] ['tenkhoa'].'<br>';
    echo 'Năm học: '.$nhoc[$namhoc];    
?></strong>
</div>
<br>
<?php if(empty($thangs)){?>
	<h2>Năm Học Chưa Được Tạo</h2>"
	<?php }elseif(empty($chidoans)){?>
		<h2>Chi Đoàn Chưa Có Đoàn Viên Nào</h2>
	<?php }else{echo $this->Form->create('Tgdongdoanphikhoa',array('type'=>'post','url'=>array('controller'=>'tgdongdoanphikhoas','action'=>'doanp',$khoa_id)));?>
	<table>
    <tr>
    <td>
	<?php echo $form->input('chon',array('id'=>'chon','label'=>'Đối tượng','type'=>'select','options'=>array(0=>'Sinh viên',1=>'Cán bộ')));?>
	</td>
    <td>
    <div id='khoc'>
	<?php echo $form->input('khoahoc',array('id'=>'khoahoc','label'=>'Khóa học','type'=>'select','options'=>$khoahocs,'empty'=>'--Tất cả--'));?>
	</div>
    </td>
    <td>	<?php echo $form->input('namhoc_id',array('id'=>'namhoc_id','label'=>'Năm học','type'=>'select','options'=>$namhocs,'selected'=>$namhoc));?></td>
	</tr>
    </table>
    <div id='dscd'>
    <?php echo $html->link('Xuất excel',array('controller'=>'tgdongdoanphikhoas','action'=>'xuatexcel',$khoa_id,$namhoc,0,0));?>
    <?php
    	$url = array('controller'=>'tgdongdoanphikhoas','action'=>'xoaddong','params'=>$khoa_id."_".$namhoc);
    	echo $ctable->doanphkhoa('Tgdongdoanphikhoa',$thangs,$chidoans,$dulieu,$dathu,$doanphi,$url,$soluong,$tongtiens);
	?>
	</div>
<div align="center" style="margin-top: 2px;">
 <?php
	   echo $this->Form->end(__('Lưu', true));
	}
?>
</div>
</div>
</div>
<?php $this->Js->get('#chon')->event('change',
							$this->Js->request(array('controller' => 'tgdongdoanphikhoas', 'action' => 'updatechidoan',$khoa_id),
							array('update' => '#dscd','async' => true,
							'dataExpression' => true,'method' => 'post',
							'data' => $js->serializeForm(array('isForm' => false, 'inline' => true)))));?>
<?php $this->Js->get('#khoahoc')->event('change',
							$this->Js->request(array('controller' => 'tgdongdoanphikhoas', 'action' => 'updatechidoan',$khoa_id),
							array('update' => '#dscd','async' => true,
							'dataExpression' => true,'method' => 'post',
							'data' => $js->serializeForm(array('isForm' => false, 'inline' => true)))));?>
<?php $this->Js->get('#namhoc_id')->event('change',
							$this->Js->request(array('controller' => 'tgdongdoanphikhoas', 'action' => 'updatechidoan',$khoa_id),
							array('update' => '#dscd','async' => true,
							'dataExpression' => true,'method' => 'post',
							'data' => $js->serializeForm(array('isForm' => false, 'inline' => true)))));?>